package com.quad.innovators.salesease.exception;

import com.quad.innovators.salesease.enums.ResultCode;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class BusinessException extends RuntimeException {
    /**
     * 错误代码
     */
    private Integer errorCode;

    /**
     * 错误信息
     */
    private String errorMsg;

    /**
     * 快捷方法
     * @param resultCode 枚举
     * @return 自定义异常
     */
    public static BusinessException resultCode(ResultCode resultCode){
        return new BusinessException(resultCode.getCode(), resultCode.getMsg());
    }
}
